{include file="common/pc/header" title="账号信息修改" /}

<style>
</style>

<form class="layui-form auto-process-label" action="" method="post" enctype="multipart/form-data">
    <div class="layui-card">
        <div class="layui-card-header">企业基本信息</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">企业名称</label>
                <div class="layui-input-inline">
                    <input type="text" autocomplete="off" class="layui-input readonly" value="{$enterprise.title}"
                           readonly disabled/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系人</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="contacter" value="{$enterprise.contacter}" placeholder="请输入联系人名称"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="phone" value="{$enterprise.phone}" placeholder="请输入联系电话" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Logo</label>
                <div class="layui-input-inline">
                    <div class="layui-upload">
                        <input type="hidden" name="logo" id="logo" value="{$enterprise.logo}"/>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img layui-upload-logo" id="logoImage" src='{$enterprise.logo}'
                                 onerror="this.src='__IMAGES__/avatar.png'"/>
                        </div>
                        <button type="button" class="layui-btn" id="uploadLogo">上传图片</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">钉钉相关配置</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">corpid</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="corpid" value="{$corpid}" placeholder="请输入corpid" autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <a href="">如何获取corpid和corpsecret？</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">cropsecret</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="password" name="corpsecret" value="{$corpsecret}" placeholder="请输入cropsecret"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <input type="checkbox" lay-skin="switch" lay-filter="corpsecret" lay-text="显示|隐藏"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">appid</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="appid" value="{$appid}" placeholder="请输入appid" autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <a href="">如何获取appid和appsecret？</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">appsecret</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="password" name="appsecret" value="{$appsecret}" placeholder="请输入appsecret"
                           autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <input type="checkbox" lay-skin="switch" lay-filter="appsecret" lay-text="显示|隐藏"/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">首页跳转地址配置</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">手机浏览器</label>
                <div class="layui-input-inline layui-input-inline-long">
                    <input type="text" name="homePageMobile" value="{$homePage.mobile}"
                           autocomplete="off"
                           class="layui-input" placeholder="留空表示系统默认跳转地址"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">PC浏览器</label>
                <div class="layui-input-inline layui-input-inline-long">
                    <input type="text" name="homePagePc" value="{$homePage.pc}"
                           autocomplete="off"
                           class="layui-input" placeholder="留空表示系统默认跳转地址"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">钉钉电脑端APP</label>
                <div class="layui-input-inline layui-input-inline-long">
                    <input type="text" name="homePageDingPc" value="{$homePage.dingPc}"
                           autocomplete="off"
                           class="layui-input" placeholder="留空表示系统默认跳转地址"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">钉钉手机端APP</label>
                <div class="layui-input-inline layui-input-inline-long">
                    <input type="text" name="homePageDingMobile" value="{$homePage.dingMobile}"
                           autocomplete="off"
                           class="layui-input" placeholder="留空表示系统默认跳转地址"/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">登录相关配置</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">钉钉登录</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    {php}
                    $checked = (!isset($loginType['ding']) || $loginType['ding']) ? "checked":"";
                    {/php}
                    <input type="checkbox" name="dingLogin" lay-skin="switch" lay-text="开启|关闭" {$checked}/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号登录</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    {php}
                    $checked = (!isset($loginType['mobile']) || $loginType['mobile']) ? "checked":"";
                    {/php}
                    <input type="checkbox" name="mobileLogin" lay-skin="switch" lay-text="开启|关闭" {$checked}/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名登录</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    {php}
                    $checked = (!isset($loginType['username']) || $loginType['username']) ? "checked":"";
                    {/php}
                    <input type="checkbox" name="usernameLogin" lay-skin="switch" lay-text="开启|关闭" {$checked}/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">短信相关配置</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">guestName</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="smsGuestName" value="{$smsConfig.guestName}" placeholder="请输入短信guestName"
                           autocomplete="off"
                           class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">key</label>
                <div class="layui-input-inline layui-input-inline-mid">
                    <input type="text" name="smsKey" value="{$smsConfig.key}" placeholder="请输入短信key"
                           autocomplete="off"
                           class="layui-input"/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="configSubmit"> 保 存</button>
        </div>
    </div>
</form>

<script>
    layui.use('form', function () {
        var form = layui.form;

        form.on('switch(corpsecret)', function (data) {
            $("input[name='corpsecret']").attr('type', data.elem.checked ? 'text' : 'password');
        });
        form.on('switch(appsecret)', function (data) {
            $("input[name='appsecret']").attr('type', data.elem.checked ? 'text' : 'password');
        });
        form.on("submit(configSubmit)", function (data) {
            g.loading();
            $.post("", data.field, function (ret) {
                g.loading(false);
                layer.alert(ret.msg);
            }, "json");
            return false;
        });
    });
    layui.use('upload', function () {
        var $ = layui.jquery,
            upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#uploadLogo',
            url: '/core/file/upload',
            accept: 'images',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#logoImage').attr('src', result); //图片链接（base64）
                });
            },
            done: function (res) {
                //如果上传失败
                if (res.code == 0 || !res.data || !res.data.fileUrl) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("#logo").val(res.data.fileUrl);
            }
        });
    });
</script>

{include file="common/pc/footer"/}